<!--
@file customizedAuditPop.html
@Date 2023-09-23, 周六, 15:36
@description 文件说明
我的空间 定制审核弹窗
-->
<!DOCTYPE html>
<html lang="en">

<head>
        <meta charset="utf-8" />
        <link rel="apple-touch-icon" sizes="76x76" href="../assets/img/favicon.ico">
        <link rel="icon" type="image/png" href="../assets/img/favicon.ico">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>数据要素流通平台</title>
        <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
            name='viewport' />
		<!-- <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.0/css/bootstrap-grid.css" rel="stylesheet"> -->
		<link href="../vendor/bootstrap-grid.css" rel="stylesheet">
        <!-- Google Font -->
        <!-- Main CSS -->
        <link href="../assets/css/main.css" rel="stylesheet" />
        <link href="../assets/layui/css/layui.css" rel="stylesheet">
        <!-- Animation CSS -->
        <link href="../vendor/aos.css" rel="stylesheet" />
        <style>
            .card-footer {
                text-align: center;
            }

            .card-footer button {
                margin-left: 40px;
            }

            p {
                font-size: 16px;
            }

            .main {
                margin-top: 10px;
            }
        </style>

    </head>

<body>
    <div class="main col-md-12">
        <h2>承接的定制详情</h2>
        <form id="customForm" class="layui-form" lay-filter="customForm">
            <div class="row form-group">
                <div class="col form-group">
                    <p class="form-group">请求用户：</p>
                    <input type="text" class="form-control" placeholder="用户名称" name="userName" required="" disabled>
                </div>
                <div class="col form-group">
                    <p class="form-group">联系电话：</p>
                    <input type="text" class="form-control" placeholder="联系人" name="phonenumber" required="" disabled>
                </div>
            </div>
            <div class="row form-group">
                <div class="col form-group">
                    <p class="form-group">联系邮箱：</p>
                    <input type="text" class="form-control" placeholder="联系邮箱" name="email" required="" disabled>
                </div>
                <div class="col form-group">
                    <p class="form-group">政府人员：</p>
                    <input type="text" class="form-control" placeholder="联系人" name="isGov" required="" disabled>
                </div>
            </div>
            <div class="row form-group">
                <div class="col form-group">
                    <p class="form-group">请求承接的定制名称</p>
                    <input type="text" class="form-control" placeholder="请求承接的定制名称" name="name" required="" disabled>
                </div>
            </div>
            <div class="row form-group">
                <div class="col form-group">
                    <p class="form-group">需求描述：</p>
                    <textarea class="form-control" id="" rows="3" name="productDetail" placeholder="需求描述" disabled></textarea>
                </div>
<!--                <div class="col form-group">-->
<!--                    <p class="form-group">需求描述：</p>-->
<!--                    <textarea class="form-control" id="" rows="3" name="productDetail" placeholder="需求描述" disabled></textarea>-->
<!--                </div>-->
            </div>
<!--            <div class="row form-group">-->
<!--            <div class="col form-group">-->
<!--                <p class="form-group">预期价格：</p>-->
<!--                <input type="number" class="form-control" placeholder="金额" required="" name="price" disabled>-->
<!--            </div>-->
<!--            </div>-->
<!--            <div class="row form-group">-->
<!--                <div class="col form-group">-->
<!--                    <p class="form-group">产品定义：</p>-->
<!--                    <textarea class="form-control" id="" rows="3" placeholder="请填写产品定义"></textarea>-->
<!--                </div>-->
<!--            </div>-->
            <div class="row form-group">
                <div class="col form-group">
                    <p class="form-group">审核意见：</p>
                    <textarea class="form-control" name="auditInfo" rows="3" placeholder="请填写审核意见"></textarea>
                </div>
            </div>
<!--            <div class="row form-group">-->
<!--                <div class="col form-group">-->
<!--                    <p class="form-group">产品信息补充：</p>-->
<!--                    <textarea class="form-control" id="" rows="3" placeholder="请填写产品信息补充"></textarea>-->
<!--                </div>-->
<!--            </div>-->
        </form>

        <div class="form-group" style="float: right;">
            <button class="btn btn-success" type="button" id="pass"> &nbsp;通过&nbsp;</button>
            <button class="btn btn-danger" type="button" id="overrule">不通过</button>
        </div>
    </div>


    <!--------------------------------------
JAVASCRIPTS
--------------------------------------->
    <script src="../vendor/jquery.min.js" type="text/javascript"></script>
    <script src="../vendor/popper.min.js" type="text/javascript"></script>
    <script src="../vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="../vendor/share.js" type="text/javascript"></script>
    <script src="../js/functions.js" type="text/javascript"></script>
    <!-- <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.0/js/bootstrap.bundle.js"></script> -->
    <script src="../vendor/bootstrap.bundle.js"></script>
    <script src="../assets/layui/layui.js" type="text/javascript"></script>
    <script src="../js/tool.js" type="text/javascript"></script>

    <!-- Animation -->
    <script src="../vendor/aos.js" type="text/javascript"></script>


    <script>
        $(function () {
            const form=layui.form;
            // 获取URL中的查询参数部分
            const queryString = window.location.search;
            // 解析查询参数字符串，将其转换为对象
            const urlParams = new URLSearchParams(queryString);
            // 获取associateId参数的值 定制信息的id
            const associateId =Number(urlParams.get('associateId'))
            const id =Number( urlParams.get('id'))
            const createUserId=Number(urlParams.get('createUserId'))
            console.log('associateId', associateId)
            console.log('id', id)
            let index = parent.layer.getFrameIndex(window.name);
            // getDetailReq(associateId).then(res=>{
            //    const data=res.data;
            //    form.val('customForm',data)
            // })
            formRender(createUserId,associateId)
            $('#pass').on('click',function (){
                auditReq(id,2)//通过
            })

            $('#overrule').on('click',function (){
                const auditInfo=form.val('customForm').auditInfo
                auditReq(id,3,auditInfo)//驳回
            })
            /**
             * @description:函数描述 渲染详情表单
             * @return 返回值
             */
            function formRender(createUserId,associateId) {
                getDetailReq(associateId).then(res=>{
                    const customData=res.data;
                    userInfo(createUserId).then(res=>{
                        const userData=res.data
                        const formData={
                            "userName":userData.userName,
                            "phonenumber":userData.phonenumber,
                            "email":userData.email,
                            "isGov":userData.isGov===1?'是':'否',
                            "name":customData.name,
                            "productDetail":customData.productDetail
                        }
                        form.val('customForm',formData)
                    })
                })
            }
            /**
             * @description:函数描述 获取承接定制详情
             * @return {Promise}
             * @param id
             */
            function getDetailReq(id){
                return new Promise(function (resolve, reject) {
                    $.ajax({
                        url: window.Http +`/CustomizeRequest/${id}`,
                        type:'get' ,
                        headers: {
                            'Authorization': "Bearer " + sessionStorage.getItem('Token')
                        },
                        success: function (res) {
                            if (res.code === 200) {
                                resolve(res)
                            } else {
                                reject(new Error('错误'))
                                layer.msg(res.msg)
                            }
                        }
                    })
                })
            }
            /**
             * @description:函数描述 获取承接用户详情
             * @return {Promise}
             * @param id
             */
            function userInfo(id) {
              return new Promise(function (resolve, reject) {
                  $.ajax({
                      url: window.Http + `/system/user/${id}`,
                      type:'GET' ,
                      headers: {
                          'Authorization': "Bearer " + sessionStorage.getItem('Token')
                      },
                      success: function (res) {
                          if (res.code === 200) {
                              resolve(res)
                          } else {
                              reject(new Error('错误'))
                              layer.msg(res.msg)
                          }
                      }
                  })
              })
            }
            function auditReq(id,status,auditResult='') {
                $.ajax({
                    timeout:30000,
                    url: window.Http + "/audit/log/operate",
                    type: 'POST',
                    headers: {
                        'Authorization': "Bearer " + sessionStorage.getItem('Token')
                    },
                    contentType: 'Application/json',
                    data:JSON.stringify({
                        id,
                        status,
                        auditResult
                    }),
                    success: function (res) {
                        if (res.code === 200) {
                            layer.msg('审核成功')
                            parent.layer.close(index);
                        }else {
                            layer.msg(res.msg)
                        }
                    }
                })
            }


        })
    </script>
    <script src="../js/leg-tree.js" type="text/javascript" charset="utf-8"></script>
    <script>

    </script>
</body>

</html>
    <title></title>
